package com.qf.usermanageradmin.service.impl;

import com.qf.usermanageradmin.entity.LoginUser;
import com.qf.usermanageradmin.entity.User;
import com.qf.usermanageradmin.entity.UserDTO;
import com.qf.usermanageradmin.mapper.LoginMapper;
import com.qf.usermanageradmin.service.LoginService;
import com.qf.usermanageradmin.utils.NoUserException;
import org.apache.catalina.mapper.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class LoginServiceImpl implements LoginService {

    @Autowired
    private LoginMapper userMapper;

    @Override
    public User login(LoginUser loginUser) {
        User user = userMapper.login(loginUser);
        if (user == null){
            throw new NoUserException("用户名或密码错误");
        }
        return user;
    }

    @Override
    public List<User> list(UserDTO userDTO) {
        return userMapper.list(userDTO);
    }

    @Override
    public int batchDelete(List<Integer> ids) {
        return userMapper.batchDelete(ids);
    }

    @Override
    public int add(User user) {
        return userMapper.add(user);
    }

    @Override
    public int editById(User user) {
        return userMapper.editById(user);
    }
}
